// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import Element from 'element-ui'
import 'normalize.css'
import 'element-ui/lib/theme-chalk/index.css'

import '@/styles/index.scss' // global css
import * as filters from './filters'
import './icons' // icon
import store from './store'
import {
  getToken
} from './utils/auth';
// import VuePhotoSwipe from './components/Photoswipe/index'
import xdSelect from './components/xdSelect';
import './mock'

Vue.use(Element)
Vue.component('xd-select', xdSelect)
// Vue.use(VuePhotoSwipe) 
Vue.config.productionTip = false

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

router.beforeEach((to, from, next) => {
  if (to.path == '/login') {
    next()
  } else {
    if (!getToken()) {
      next({
        path: '/login'
      })
    } else {
      if (getToken() == 'ok') {
        next();
      } else {
        if (to.path != '/login' && to.path != '/scan') {
          next({
            path: '/login'
          });
        }else{
          next();
        }
      }
    }
  }
})

import waves from "./directive/waves"; // 水波纹指令
Vue.directive('waves', waves)
import baseMixin from "./mixins/baseMixin";
Vue.mixin(baseMixin);
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
